﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TechTree.Stalk.Roots.Database;
using TechTree.Stalk.Roots.Databases.Factories;
using TechTree.Stalk.Roots.Globalization.Interfaces;

namespace TechTree.Stalk.Roots.Globalization.Dictionaries
{
    public class DatabaseDictionary : ISourceDictionary
    {
        public string GetText(string key_)
        {
            DatabaseContext context = DatabaseContextFactory.CreateDatabaseContext("");
            IDbConnection dbConnection = context.CreateOpenConnection();
            IDbCommand command = context.CreateStoredProcCommand("", dbConnection);

            command.CommandType = System.Data.CommandType.StoredProcedure;
            command.CommandText = "<your stored proc>";
            command.Connection = dbConnection;

            SqlParameter param1 = new SqlParameter("<your parameter>", 1);
            command.Parameters.Add(param1);
            //[...]

            SqlParameter returnValue = new SqlParameter("ReturnValue", 1);
            returnValue.Direction = System.Data.ParameterDirection.ReturnValue;
            command.Parameters.Add(returnValue);

            command.Connection.Open();
            command.ExecuteNonQuery();
            int result = (int)command.Parameters["ReturnValue"];
            command.Connection.Close();

            return string.Empty;
        }

        public string GetText(string key_, CultureInfo cultureInfo_)
        {
            throw new NotImplementedException();
        }
    }
}
